﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Office.Interop.Excel;

namespace ObjectModel.Excel.Old
{
    /// <summary>
    /// Base class for extending an Excel range object to provide events.
    /// </summary>
    public abstract class ObservableRangeBase : ResizeableRange
    {
        public delegate void RangeChangedEventHandler(object sender, RangeChangedEventArgs e);

        public event RangeChangedEventHandler RangeChanged;
        public event EventHandler RangeSelected;

        // Parameterless constructor for serialization.
        public ObservableRangeBase() : base() { }
        
        public ObservableRangeBase(Range range) : base(range) { }

        public void OnRangeChanged(RangeChangedEventArgs e)
        {
            if (RangeChanged != null)
                RangeChanged(this, e);
        }

        public void OnRangeSelected(EventArgs e)
        {
            if (RangeSelected != null)
                RangeSelected(this, e);
        }
    }
}
